package com.trace.meat.controller;

import com.trace.meat.entity.Lic;
import com.trace.meat.entity.Process;
import com.trace.meat.service.ProcessService;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Process)表控制层
 *
 * @author makejava
 * @since 2021-06-19 11:17:29
 */
@RestController
@RequestMapping("process")
public class ProcessController {
    /**
     * 服务对象
     */
    @Resource
    private ProcessService processService;

    /**
     * 通过主键查询单条数据
     *
     * @param proc_id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Process selectOne(Integer proc_id) {
        return this.processService.queryById(proc_id);
    }
    /**
     * 更新数据
     *
     */
    //http://127.0.0.1:11451/process/updateOne?procId=1&bid=2
    @GetMapping("updateOne")
    public Process update(Integer proc_id, Integer bid, Integer aid, Integer pid) {
        Process process=new Process();
        process.setProcId(proc_id);
        process.setBid(bid);
        process.setAid(aid);
        process.setPid(pid);
        return processService.update(process);
    }
    /**
     * 删除数据
     */
    //http://127.0.0.1:11451/process/deleteOne?procId=2
    @GetMapping("deleteOne")
    public boolean deleteById(Integer proc_id) {
        return processService.deleteById(proc_id);
    }
    /**
     * 插入新数据
     *
     * @param bid 经营者编号
     * @param aid 牲畜编号
     * @param pid 产品编号
     * @return 单条数据
     */
    @GetMapping("insertOne")
    public Process insert(Integer bid,Integer aid,Integer pid) {
        Process process=new Process();
        process.setPid(pid);
        process.setBid(bid);
        process.setAid(aid);
        return processService.insert(process);
    }

}
